<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.org/ui">

    <ui:decorate template="/resources/template/modelo.xhtml">
        <ui:define name="centro">


            <f:view encoding="ISO-8859-1">  


                


                <h:form id="formCadastroAutor">
                    <p:focus context="panel"/>  
                    <p:messages id="messages" autoUpdate="true" closable="true"  /> 
                    <p:panel id="panel"  header="Cadastro de Autor" style="margin-bottom:10px;"  >  

                        <h:panelGrid id="grid" columns="3">

                            <h:outputText  value="Último nome:" />
                            <h:inputText id="ultimoNome" label="Ultimo Nome" value="#{autorBean.autor.ultimoNome}" required="true" requiredMessage="Ultimo nome é obrigatório" />
                            <p:message for="ultimoNome" display="icon"/>  
                            <h:outputText value="Restante do nome:" />
                            <h:inputText  id="restanteNome" label="Restante do Nome" value="#{autorBean.autor.restanteNome}" required="true" requiredMessage="Restante do nome é obrigatório" />
                            <p:message for="restanteNome" display="icon"/> 

                        </h:panelGrid>
                        <h:panelGrid columns="2">
                            <h:outputText value="Lattes:" />
                            <p:inputText value="#{autorBean.autor.lattes}"></p:inputText>
                        </h:panelGrid>

                        <h:panelGrid columns="3">
                            <h:outputText value="Instituição:" />  
                            <p:selectOneMenu value="#{autorBean.autor.instituicaoAutor.id}" effect="fade"   >
                                <f:selectItem itemLabel="Selecione" itemValue="" />
                                <f:selectItems value="#{instituicaoBean.listarInstituicoes()}" var="inst"  itemLabel="#{inst.nome} - #{inst.municipio} " itemValue ="#{inst.id}"  />
                            </p:selectOneMenu>
                            <p:commandButton icon="ui-icon-refresh" ajax="false"  /> 
                        </h:panelGrid>

                        <h:panelGrid columns="1">
                            <h:commandLink  actionListener="#{instituicaoBean.novaInstituicao}"  action="/cadastros/instituicoes/cadastroInstituicao" 
                                            target="_blank" style="margin-right:20px;" immediate="true"   >  
                                <h:outputText value="Não encontrou a instituição?" />  
                            </h:commandLink>
                            
                        </h:panelGrid>
                        <h:panelGrid columns="1">
                            <p:commandButton id="cadastrarAutor" value="Cadastrar Autor" update="grid" action="#{autorBean.cadastroAutor}"  ajax="false" /> 
                        </h:panelGrid>



                    </p:panel>

                </h:form>    
            </f:view>
        </ui:define>
    </ui:decorate>
</html>